package com.cxx.purchasecharge.dal;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.AccountingModeCode;
import com.cxx.purchasecharge.core.model.persistence.AccountingType;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface AccountingTypeDao extends GenericCRUDDao <AccountingType, Long>
{
    public AccountingType findById (long id);

    @Query (value = "select a from AccountingType a where a.name=?1")
    public AccountingType findByName (String name);
    
    @Query (value = "select a from AccountingType a where a.accountingMode=?1")
    public List<AccountingType> findByMode (AccountingModeCode mode);
    
    @Query (value = "select a from AccountingType a order by a.accountingMode")
    public List<AccountingType> getAll ();

}
